package com.zbkj.common.enums;

/**
 * 代认养周期类型枚举
 * +----------------------------------------------------------------------
 * @author xiaolic
 * +----------------------------------------------------------------------
 */
public enum FosterCycleTypeEnum {

    DAY("天", "day"),
    WEEK("周", "week"),
    MONTH("月", "month"),
    QUARTER("季度", "quarter"),
    YEAR("年", "year");

    private final String name;
    private final String value;

    FosterCycleTypeEnum(String name, String value) {
        this.name = name;
        this.value = value;
    }

    public String getName() {
        return name;
    }

    public String getValue() {
        return value;
    }

    /**
     * 根据值获取对应的枚举
     * @param value 值
     * @return 枚举
     */
    public static FosterCycleTypeEnum getByValue(String value) {
        for (FosterCycleTypeEnum typeEnum : FosterCycleTypeEnum.values()) {
            if (typeEnum.getValue().equals(value)) {
                return typeEnum;
            }
        }
        return null;
    }

    /**
     * 根据名称获取对应的枚举
     * @param name 名称
     * @return 枚举
     */
    public static FosterCycleTypeEnum getByName(String name) {
        for (FosterCycleTypeEnum typeEnum : FosterCycleTypeEnum.values()) {
            if (typeEnum.getName().equals(name)) {
                return typeEnum;
            }
        }
        return null;
    }
}
